<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-tagInfo-add">
			<div class="form-group">	
				<label class="col-sm-3 control-label">标签名称：</label>
				<div class="col-sm-8">
					<input id="tagQuence" name="tagQuence" class="form-control" type="text">
				</div>
			</div>
			
			<div class="form-group">	
				<label class="col-sm-3 control-label">厂商名称：</label>
				<div class="col-sm-8">
					<!-- <input id="companyName" name="companyName" class="form-control" type="text"> -->
					<select id="companyName" name="companyName"  class="form-control m-b" th:with="type=${@garden.getGarden()}">
	                    <option value="">---请选择---</option>
	                    <option th:each="garden : ${type}" th:text="${garden.gardenName}" th:value="${garden.teaGardenNo}"></option>
	                </select>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">溯源码：</label>
				<div class="col-sm-8">
					<!-- <input id="productCode" name="productCode" class="form-control" type="text"> -->
				<select id="productCode" name="productCode"  class="form-control m-b" disabled="disabled">
	                    <option value="">---请选择---</option>
	                </select>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">产品名称：</label>
				<div class="col-sm-8">
					<input id="productName" name="productName" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">原料来源：</label>
				<div class="col-sm-8">
					<input id="materialSource" name="materialSource" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">加工工艺：</label>
				<div class="col-sm-8">
				<!-- 	<input id="processTech" name="processTech" class="form-control" type="text"> -->
					<select id="processTech" name="processTech" class="form-control m-b" th:with="type=${@dict.getType('gh_process_tech')}">
	                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
	                </select>
				</div>
			</div>
			<div class="form-group">	
				 <label class="col-sm-3 control-label">生产日期：</label>
				<div class="col-sm-8">
					<input id="productDate" name="productDate" class="form-control" type="text" placeholder="例如：180101">
				</div> 
			<!-- 	<label class="col-sm-3 control-label">生产日期：</label>
				<div class="col-sm-8">
				    <div class="form-group">
				        <div class="input-group date"> <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
				            <input type="text" class="form-control" id="productDate" name="productDate" value="2018-04-20">
				        </div>
				    </div>
				</div> -->
				
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">批次号：</label>
				<div class="col-sm-8">
					<input id="batchNo" name="batchNo" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">产品等级：</label>
				<div class="col-sm-8">
					<select id="productRank" name="productRank" class="form-control m-b" th:with="type=${@dict.getType('gh_product_level')}">
	                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
	                </select>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">保质期：</label>
				<div class="col-sm-8">
					<input id="expiredDate" name="expiredDate" class="form-control" type="text" placeholder="例如：180101">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">产品质量认证编号：</label>
				<div class="col-sm-8">
					<input id="productCertNum" name="productCertNum" class="form-control" type="text">
				</div>
			</div>
		<!-- 	<div class="form-group">	
				<label class="col-sm-3 control-label">生产信息校验码：</label>
				<div class="col-sm-8">
					<input id="proCheckCode" name="proCheckCode" class="form-control" type="text">
				</div>
			</div> -->
			<div class="form-group">	
				<label class="col-sm-3 control-label">经销商名称：</label>
				<div class="col-sm-8">
					<input id="dealerName" name="dealerName" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">销售时间：</label>
				<div class="col-sm-8">
					<input id="saleTime" name="saleTime" class="form-control" type="text" placeholder="例如：180101"> 
				</div>
			</div>
			  <div class="form-group">	
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <input id="remarks" name="remarks"  class="form-control" type="text">
                </div>
            </div>
		<!-- 	<div class="form-group">	
				<label class="col-sm-3 control-label">销售信息校验码：</label>
				<div class="col-sm-8">
					<input id="saleCheckCode" name="saleCheckCode" class="form-control" type="text">
				</div>
			</div> -->
			
		</form>
	</div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "module/tagInfo"
		$("#form-tagInfo-add").validate({
			rules:{
				tagQuence:{
					required:true,
					maxlength: 128
				},
				companyName:{
					required:true,
					maxlength: 14
				},
				productCode:{
					required:true,
					maxlength: 20
				},
				productName:{
					required:true,
					maxlength: 14
				},
				materialSource:{
					required:true,
					maxlength: 14
					
				},
				batchNo:{
					required:true,
					isDigits:true,
					maxlength: 14,
					minlength: 14
				},
				productCertNum:{
					required:true,
					maxlength: 20
				},
				dealerName:{
					required:true,
					maxlength: 12
				},
				productDate:{
					required:true,
					isDigits:true,
					minlength: 6,
        			maxlength: 6
				},
				expiredDate:{
					required:true,
					isDigits:true,
					minlength: 6,
        			maxlength: 6
				},
				saleTime:{
					required:true,
					isDigits:true,
					minlength: 6,
        			maxlength: 6
				},
			}
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	            $.operate.save(prefix + "/add", $('#form-tagInfo-add').serialize());
	        }
	    }
		
		$("#companyName").change(function(){
			 $("#productCode").removeAttr("disabled");
			 var  companyName = $("#companyName").find("option:selected").val(); 
			 if(companyName == "") { 
				 $("#productCode").empty().append("<option value=''>---请选择---</option>"); 
				 $("#productCode").attr("disabled","disabled");
				 return false;
				 }
		    $("#productCode").empty().append("<option value=''>---请选择---</option>");
		     $.ajax({ 
		    	url:ctx +'module/product/getProdunctCodeByGarden', 
		    	type:"post",
		    	dataType:"json", 
		    	data: {teaGardenNo : $(this).val()}, 
		    	success: function (data) { 
		    		 for(var i = 0, len = data.length; i < len; i++) { 
		    			$("#productCode").append($("<option value='" + data[i] + "'>" + data[i] + "</option>")); 
		    			}  
		    		}, 
		    	error : function(request) {
        			$.modal.alertError("系统错误");
        		},
		    	}); 
		    	
			});
	</script>
</body>
</html>
